﻿using Ducu.BLL.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ducu.SRV.Query
{
    public static class OnMessage
    {
        public static IQueryable<Message> Get(
            this IQueryable<Message> source, User sendTo)
        {
            return source.Where(m => m.SendTo == sendTo);
        }

        public static IQueryable<Message> GetFrom(
            this IQueryable<Message> source, User sendFrom)
        {
            return source.Where(m => m.SendFrom == sendFrom);
        }

        public static IQueryable<Message> New(
            this IQueryable<Message> source, User sendTo)
        {
            return source.Get(sendTo).Where(m=>!m.HasRead);
        }
    }
}
